bosch_shc: add child lock switch entities - #181423
Conversation
Devices exposing the ChildProtection service (micromodule shutters/ blinds/light-attached/relays/impulse-relays/dimmers, BSM light switches) or the thermostat-service child lock (thermostats, room thermostats, wall thermostats) had no way to control child lock from Home Assistant. boschshcpy already models both forms (bool childLockActive vs. a ThermostatService.State enum) via a uniform child_lock property/setter, so this wires them into the existing generic SHCSwitch entity with two SWITCH_TYPES entries. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W1XR86oNP5B49zG5obz7Cw
|
Hey there @tschamm, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
🟡 Changes recommended
User-facing documentation and coverage of the BSM unique-ID collision scenario are missing.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds Bosch SHC child-lock switch entities for thermostats, relays, dimmers, blinds, shutters, and light switches.
Changes:
- Adds Boolean and thermostat-enum child-lock switches.
- Prevents unique-ID collisions using a suffix.
- Adds translations, icons, fixtures, and tests.
File summaries
| File | Description |
|---|---|
homeassistant/components/bosch_shc/switch.py |
Registers and controls child-lock switches. |
homeassistant/components/bosch_shc/strings.json |
Adds the child-lock entity name. |
homeassistant/components/bosch_shc/icons.json |
Adds the child-lock icon. |
tests/components/bosch_shc/conftest.py |
Adds device doubles and bucket fixtures. |
tests/components/bosch_shc/test_switch.py |
Tests thermostat and relay child locks. |
Review details
Suppressed comments (1)
homeassistant/components/bosch_shc/switch.py:206
- Add a BSM-specific test that verifies the existing light switch and new child-lock switch register with distinct unique IDs. The suffix was introduced specifically to prevent this collision, but the current tests only instantiate devices that create one switch, so a regression would not be detected.
*session.device_helper.light_switches_bsm,
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| for switch in session.device_helper.camera_360 | ||
| ) | ||
|
|
||
| entities.extend( |
Per Copilot review on home-assistant#181423: the existing tests only covered devices that get a single switch entity, so a unique_id collision between a BSM light switch's primary switch and its new child-lock switch wouldn't have been caught. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W1XR86oNP5B49zG5obz7Cw
There was a problem hiding this comment.
🟢 Approval recommended
The implementation matches the pinned library APIs and includes representative coverage for both child-lock models and ID collisions.
Review details
- Files reviewed: 5/5 changed files
- Comments generated: 0 new
- Review effort level: Balanced
Proposed change
None of the devices that expose Bosch's child-lock feature had a way to control it from Home Assistant —
switch.pynever wired up theChildProtectionservice (boolchildLockActive) or the thermostat-service child lock (ThermostatService.Stateenum).boschshcpyalready models both forms behind a uniformchild_lockproperty/setter (bool getter+setter onChildProtection-mixed devices, enum getter / bool setter on thermostat-family devices), so this just wires them into the existing genericSHCSwitchentity with two newSWITCH_TYPESentries:child_lock(boolon_value=True) for: micromodule shutters/blinds/light-attached/relays/impulse-relays/dimmers, and BSM light switches.child_lock_thermostat(on_value=ThermostatService.State.ON) for: thermostats, room thermostats, wall thermostats.Both share the same
translation_key/icon (child_lock,mdi:lock). Also added aunique_id_suffixparam toSHCSwitch.__init__(mirroring the existingSHCRoutingSwitchpattern) so a device that already has a primary switch entity (e.g. a BSM light switch) doesn't collide unique_ids with its new child-lock entity.No dependency bump needed —
boschshcpy0.6.4 (already pinned) has had thischild_lockproperty since long before this version.Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests:
🤖 Generated with Claude Code
https://claude.ai/code/session_01W1XR86oNP5B49zG5obz7Cw